package com.model;

import java.sql.Timestamp;

/**
 * 点赞实体类，关联用户和帖子
 */
public class Like {
    private int id; // 点赞记录ID
    private int userId; // 点赞用户ID（关联users表）
    private int postId; // 被点赞帖子ID（关联posts表）
    private Timestamp createdAt; // 点赞时间
    private String username; // 冗余字段，显示点赞用户的用户名

    // 构造方法
    public Like() {}

    // 用于创建新点赞的构造方法（无需id和时间，由数据库生成）
    public Like(int userId, int postId) {
        this.userId = userId;
        this.postId = postId;
    }

    // getter和setter方法
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    public int getPostId() {
        return postId;
    }

    public void setPostId(int postId) {
        this.postId = postId;
    }

    public Timestamp getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(Timestamp createdAt) {
        this.createdAt = createdAt;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }
}